package com.ruoyi.web.controller.combat;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.MethodUseLog;
import com.ruoyi.combat.service.IMethodUseLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课题方法记录Controller
 * 
 * @author ruoyi
 * @date 2025-01-09
 */
@Api(tags = "公共服务：算法调用记录管理")
@RestController
@RequestMapping("/combat/method/log")
public class MethodUseLogController extends BaseController
{
    @Autowired
    private IMethodUseLogService methodUseLogService;

    /**
     * 查询课题方法记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @ApiOperation(value = "查询课题方法记录列表")
    @GetMapping("/list")
    public TableDataInfo list(MethodUseLog methodUseLog)
    {
        startPage();
        List<MethodUseLog> list = methodUseLogService.selectMethodUseLogList(methodUseLog);
        return getDataTable(list);
    }

    /**
     * 导出课题方法记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @ApiOperation(value = "导出课题方法记录列表")
    @Log(title = "课题方法记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MethodUseLog methodUseLog)
    {
        List<MethodUseLog> list = methodUseLogService.selectMethodUseLogList(methodUseLog);
        ExcelUtil<MethodUseLog> util = new ExcelUtil<MethodUseLog>(MethodUseLog.class);
        util.exportExcel(response, list, "课题方法记录数据");
    }

    /**
     * 获取课题方法记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @ApiOperation(value = "获取课题方法记录详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(methodUseLogService.selectMethodUseLogById(id));
    }

    /**
     * 新增课题方法记录
     */
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @ApiOperation(value = "新增课题方法记录")
    @Log(title = "课题方法记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MethodUseLog methodUseLog)
    {
        return toAjax(methodUseLogService.insertMethodUseLog(methodUseLog));
    }

    /**
     * 修改课题方法记录
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @ApiOperation(value = "修改课题方法记录")
    @Log(title = "课题方法记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MethodUseLog methodUseLog)
    {
        return toAjax(methodUseLogService.updateMethodUseLog(methodUseLog));
    }

    /**
     * 删除课题方法记录
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @ApiOperation(value = "删除课题方法记录")
    @Log(title = "课题方法记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(methodUseLogService.deleteMethodUseLogByIds(ids));
    }
}
